<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../resources/js-test.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description('Tests for value sanitization algorithm.');

var input;

var fallbackValue = '"#000000"'

input = document.createElement('input');
input.type = 'color';
shouldBe('input.value', fallbackValue);

// Valid values
shouldBe('input.value = ""; input.value', fallbackValue);
shouldBe('input.value = "#000000"; input.value', '"#000000"');
shouldBe('input.value = "#123456"; input.value', '"#123456"');
shouldBe('input.value = "#789abc"; input.value', '"#789abc"');
shouldBe('input.value = "#defABC"; input.value', '"#defabc"');
shouldBe('input.value = "#DEF012"; input.value', '"#def012"');

// Invalid values: named colors
shouldBe('input.value = "black"; input.value', fallbackValue);
shouldBe('input.value = "blue"; input.value', fallbackValue);
shouldBe('input.value = "red"; input.value', fallbackValue);
shouldBe('input.value = "purple"; input.value', fallbackValue);
shouldBe('input.value = "green"; input.value', fallbackValue);
shouldBe('input.value = "cyan"; input.value', fallbackValue);
shouldBe('input.value = "yellow"; input.value', fallbackValue);
shouldBe('input.value = "white"; input.value', fallbackValue);
shouldBe('input.value = "White"; input.value', fallbackValue);
shouldBe('input.value = "WHITE"; input.value', fallbackValue);

// Invalid values
shouldBe('input.value = "000000"; input.value', fallbackValue);
shouldBe('input.value = "#FFF"; input.value', fallbackValue);
shouldBe('input.value = " #ffffff"; input.value', fallbackValue);
shouldBe('input.value = "#ffffff "; input.value', fallbackValue);
shouldBe('input.value = "#00112233"; input.value', fallbackValue);
shouldBe('input.value = "rgb(0,0,0)"; input.value', fallbackValue);
shouldBe('input.value = "xxx-non-existent-color-name"; input.value', fallbackValue);
shouldBe('input.value = "transparent"; input.value', fallbackValue);
</script>
</body>
</html>
